package com.zch.zhongchou.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zch.zhongchou.dao.AdminMapper;
import com.zch.zhongchou.pojo.Admin;
import com.zch.zhongchou.service.AdminService;
@Service("as")
public class AdminServiceImpl implements AdminService {
	@Autowired
	private AdminMapper dao;
	
	public Map<String, Object> login(String name,String password){
		HashMap<String, Object> map = new HashMap<String,Object>();
		Admin admin = dao.getAdminByName(name);
		if(admin != null){
			if(admin.getAdminPassword().equals(password)){
				map.put("admin1", admin);
				map.put("isLogin", true);
				map.put("msg", "登录成功");
			}else{
				map.put("isLogin", false);
				map.put("msg", "密码错误");
			}
		}else{
			map.put("isLogin", false);
			map.put("msg", "此管理员账户不存在");
		}
		return map;
	}
	
	@Override
	public Admin getAdmin(int id){
		return dao.selectByPrimaryKey(id);
	}

	@Override
	public int update(Admin admin) {
		// TODO Auto-generated method stub
		return dao.updateByPrimaryKey(admin);
	}

}
